package com.qfjy.config.example4;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ScanConfig {
    /**
     * 1、定义交换机
     * 2、分别定义队列
     * 3、交换机和队列进行绑定(routingkey)
     */
    @Bean
    public DirectExchange scanDirectExchange(){
        return new DirectExchange("scanDirectExchange");
    }

    /**
     * 2、分别定义队列
     */
    @Bean
    public Queue weixinScanQueue(){
        return new Queue("weixinScanQueue");
    }

    @Bean
    public Queue zhifubaoScanQueue(){
        return new Queue("zhifubaoScanQueue");
    }

    /**
     * 3、交换机和队列进行绑定(routingkey)
     */
    @Bean
    public Binding bindWeixinQueueDirectExchange(Queue weixinScanQueue,DirectExchange scanDirectExchange){

        return BindingBuilder.bind(weixinScanQueue).to(scanDirectExchange).with("weixin");
    }
    @Bean
    public Binding bindZhifubaoQueueDirectExchange(Queue zhifubaoScanQueue,DirectExchange scanDirectExchange){

        return BindingBuilder.bind(zhifubaoScanQueue).to(scanDirectExchange).with("zhifubao");
    }
}
